//
//  CommentNavigationBar.m
//  项目三
//
//  Created by rimi1 on 2016/12/13.
//  Copyright © 2016年 Wangxingqian. All rights reserved.
//

#import "CommentNavigationBar.h"

static NSInteger spacing_ = 10;

@implementation CommentNavigationBar

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.headImage];
        [self addSubview:self.name];
        [self addSubview:self.works];
    }
    return self;
}

- (void)respondsToHead {
    if (self.tapHead) {
        self.tapHead();
    }
}

#pragma mark - get

- (UIImageView *)headImage {
    
    if (!_headImage) {
        
        CGFloat diameter = 30;
        _headImage = [[UIImageView alloc] initWithFrame:CGRectMake(spacing_ + 5, 27, diameter, diameter)];
        _headImage.layer.cornerRadius = diameter/2;
        _headImage.layer.masksToBounds = YES;
        _headImage.userInteractionEnabled = YES;
        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(respondsToHead)];
        [_headImage addGestureRecognizer:tap];
        
    }
    return _headImage;
}

- (UILabel *)name {
    
    if (!_name) {
        
        CGFloat x = CGRectGetMaxX(self.headImage.frame) + spacing_;
        _name = [[UILabel alloc] initWithFrame:CGRectMake(x, CGRectGetMinY(self.headImage.frame), kWIDTH - x - spacing_, 12)];
        _name.font = [UIFont systemFontOfSize:12];
        _name.textColor = [UIColor whiteColor];
        
    }
    return _name;
}

- (UILabel *)works {
    
    if (!_works) {
        
        _works = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMinX(self.name.frame), CGRectGetMaxY(self.name.frame) + spacing_/2, CGRectGetWidth(self.name.bounds), 12)];
        _works.font = [UIFont systemFontOfSize:12];
        _works.textColor = [UIColor whiteColor];
        
    }
    return _works;
}

@end












